
<template>
  <div style="height: 100%; width: 100%; position: relative;" ref="maindev">
    <div class="pagetop">
      <table style="width: 100%; font-size: 12px;" border="0">
        <col style="width: 7%;" />
        <col style="width: 11%;" />
        <col style="width: 1%;" />
        <col style="width: 11%;" />
        <col style="width: 7%;" />
        <col style="width: 12%;" />
        <col style="width: 7%;" />
        <col style="width: 10%;" />
        <col style="width: 7%;" />
        <col style="width: 10%;" />
        <col style="width: 7%;" />
        <col style="width: 10%;" />
        <tr>
          <td align="right">
            <el-dropdown @command="handleCommand" style="font-size: 12px;">
              <u class="el-dropdown-link">
                {{ datename }}
              </u>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item command="标本日期">
                  <font font-size="12px">标本日期</font>
                </el-dropdown-item>
                <el-dropdown-item command="接收日期">
                  <font font-size="12px">接收日期</font>
                </el-dropdown-item>
                <el-dropdown-item command="报告日期">
                  <font font-size="12px">报告日期</font>
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </td>
          <td>
            <el-date-picker v-model="searchobj.strdate" :clearable="false" type="date" placeholder="选择日期"
              value-format="yyyy-MM-dd" style="width: 100%;"> </el-date-picker>
          </td>
          <td>至</td>
          <td>
            <el-date-picker v-model="searchobj.enddate" type="date" :clearable="false" placeholder="选择日期"
              value-format="yyyy-MM-dd" style="width: 100%;"> </el-date-picker>
          </td>
          <td align="right">细菌组</td>
          <td>
            <el-select v-model="searchobj.germcomb"
              @dblclick.native="popMultipleChk(searchobj.germcomb, 'germcomb', germcombOption, '细菌组')" filterable
              clearable style="width: 100%;">
              <el-option v-for="(item, index) in germcombOption" :key="index" :value="item.data" :label="item.display">
              </el-option>
            </el-select>
          </td>
          <td align="right">病人类型</td>
          <td>
            <!-- @dblclick.native="popMultipleChk(txtpattype, 'txtpattype', pattypeOption, '病人类型选择')" -->
            <el-select v-model="searchobj.pattype" filterable clearable>
              <el-option v-for="(item, index) in pattypeOption" :value="item.data" :label="item.display"
                :key="index"></el-option>
            </el-select>
          </td>
          <td align="right">病人性别</td>
          <td>
            <el-select v-model="searchobj.patsex" style="width: 100%;" clearable>
              <el-option v-for="(item, index) in sexOption" :key="index" :label="item.label"
                :value="item.value"></el-option>
            </el-select>
          </td>
          <td align="right">申请科室</td>
          <td>
            <el-select v-model="searchobj.reqdept"
              @dblclick.native="popMultipleChk(searchobj.reqdept, 'reqdept', deptOption, '申请科室选择')" filterable clearable>
              <el-option v-for="(item, index) in deptOption" :key="index" :value="item.data" :label="item.display">
              </el-option>
            </el-select>
          </td>
        </tr>
        <tr>
          <td align="right">报告单元</td>
          <td colspan="3">
            <rm-ddl-rptunit @change="rptunitChange" v-model="searchobj.rptunitid" reporttype="20" width="100%"
              clearable></rm-ddl-rptunit>
          </td>
          <td align="right">细菌</td>
          <td>
            <el-select v-model="searchobj.germrptitemcode"
              @dblclick.native="popMultipleChk(searchobj.germrptitemcode, 'germrptitemcode', germOption, '请选择细菌项目')"
              filterable clearable style="width: 100%;">
              <el-option v-for="(item, index) in germOption" :key="index" :value="item.data"
                :label="item.display"></el-option>
            </el-select>
          </td>
          <td align="right">送检医院</td>
          <td colspan="3">
            <rm-ddl-common @change="hospitalchange" datatype="hospital" dataname="送检医院" v-model="searchobj.hospitalcode"
              width="100%" :clearable="true"></rm-ddl-common>

          </td>

          <td align="right">申请病区</td>
          <td>
            <el-select v-model="searchobj.reqward"
              @dblclick.native="popMultipleChk(searchobj.reqward, 'reqward', wardOption, '病区选择')" filterable clearable>
              <el-option v-for="(item, index) in wardOption" :key="index" :value="item.data" :label="item.display">
              </el-option>
            </el-select>
          </td>

        </tr>
        <tr>
          <td align="right">抗生素</td>
          <td colspan="3">
            <el-select v-model="searchobj.labmed"
              @dblclick.native="popMultipleChk(searchobj.labmed, 'labmed', labmedOption, '抗生素选择')" filterable clearable
              style="width:100%">
              <el-option v-for="(item, index) in labmedOption" :key="index" :value="item.data" :label="item.display">
              </el-option>
            </el-select>
            <!-- <rm-ddl-common v-model="searchobj.labmed" datatype="labmed" dataname="抗生素选择" width="100%"></rm-ddl-common> -->
          </td>
          <td align="right">耐药机制</td>
          <td>
            <!-- <el-select v-model="searchobj.rescode" clearable filterable>
                            <el-option v-for="(item,index) in resdictOption" :key="index" :label="item.display" :value="item.data">
                                <span style="float: left">{{ item.display }}</span>
                                <span style="float: right; color: #8492a6; font-size: 13px">{{ item.data }}</span>
                            </el-option>
                        </el-select> -->
            <rm-ddl-common ref="ddlrescode" datatype="resdict" dataname="耐药机制" v-model="searchobj.rescode"
              :clearable="true" :showcode="true" pclass="mini-select" width="100%" @change="resChange"></rm-ddl-common>
          </td>
          <td align="right">标本类型</td>
          <td>
            <el-select v-model="searchobj.sample"
              @dblclick.native="popMultipleChk(searchobj.sample, 'sample', specimenOption, '请选择标本类型')" filterable
              clearable>
              <el-option v-for="(item, index) in specimenOption" :key="index" :value="item.data"
                :label="item.display"></el-option>
            </el-select>
          </td>
          <td colspan="4">
            <el-checkbox true-label="1" false-label="0" v-model="searchobj.bypat">&nbsp;按病人统计</el-checkbox>
            <el-checkbox v-model="searchobj.bygerm" true-label="1" false-label="0">&nbsp;按细菌统计</el-checkbox>
            <!-- <el-radio-group v-model="searchobj.bypat" @change="bypatChange">
                            <el-radio :label="1">按病人统计</el-radio>
                            <el-radio :label="2">按细菌统计</el-radio>
                        </el-radio-group> -->
            <el-checkbox v-model="searchobj.chkEmptyAs0" true-label="1" false-label="0">&nbsp;空数值显示为0</el-checkbox>
          </td>
        </tr>
        <tr>
          <td align="right">统计方式</td>
          <td colspan="3">
            <el-radio-group v-model="searchobj.bytype" @change="TypeChange">
              <el-radio :label="'0'" style="margin-right:5px">样本类型</el-radio>
              <el-radio :label="'1'" style="margin-right:5px">申请科室</el-radio>
              <el-radio :label="'2'" style="margin-right:5px">送检医院</el-radio>
              <el-radio :label="'3'" style="margin-right:5px">全部</el-radio>
            </el-radio-group>
          </td>
          <td></td>
          <td colspan="3" align="center">
            <el-radio-group v-model="searchobj.deletedup">
              <el-radio :label="1">去除同一个病人的相同结果</el-radio>
              <el-radio :label="2">去除同一个病人同标本类型的相同结果</el-radio>
              <el-radio :label="0">不去除</el-radio>
            </el-radio-group>
          </td>
          <td colspan="4" align="right">
            <el-button @click.native="BtnQuery" v-has="'PINQUERY'" type="primary" icon="el-icon-search">查询</el-button>
            <!-- <el-button @click.native="BtnSort" icon="el-icon-sort">排序</el-button> -->
            <el-button @click.native="BtnClear" icon="el-icon-close">清除</el-button>
            <el-button @click.native="BtnExport" icon="el-icon-download">导出</el-button>
            <el-button @click.native="BtnPrint(1)" icon="el-icon-printer">打印</el-button>
            <el-button v-if="rptStyleSettingState" @click.native="BtnPrint(2)" class="el-icon-printer">打印样式设计</el-button>
          </td>
        </tr>
      </table>
    </div>
    <div class="pagecenter">
      <div class="middle-center">
        <vxe-table :data.sync="tableData" :loading="loading" :select-config="{ reserve: true }"
          :sort-config="{ trigger: 'cell' }" border height="auto" highlight-current-row class="mytable-style"
          highlight-hover-column highlight-hover-row how-header-overflow ref="xTable" resizable show-overflow size="mini"
          stripe show-header-overflow :optimization="{ animat: false }" header-align="center" :key="xTablekey"
          :span-method="rowspanMethod">
          <!-- <vxe-table-column field="cp_cnt" sortable title="序号" width="80" show-overflow></vxe-table-column> -->
          <vxe-table-column v-if="searchobj.bytype === '0'" field="bytypename" sortable title="样本类型" width="150"
            show-overflow :formatter="formatFun"></vxe-table-column>
          <vxe-table-column v-else-if="searchobj.bytype === '1'" field="bytypename" sortable title="科室" width="150"
            show-overflow :formatter="formatFun"></vxe-table-column>
          <vxe-table-column v-else-if="searchobj.bytype === '2'" field="bytypename" sortable title="送检医院" width="150"
            show-overflow :formatter="formatFun"></vxe-table-column>
          <!-- <vxe-table-column v-if="searchobj.bytype!='3'" field="allcnt" sortable title="总数" align="center" width="50" show-overflow></vxe-table-column> -->
          <vxe-table-column field="rpt_itemname" sortable title="细菌" width="150"
            v-if="searchobj.bygerm == '1'"></vxe-table-column>
          <vxe-table-column field="medname" sortable title="抗生素" width="120" show-overflow></vxe-table-column>
          <vxe-table-column field="cnt" sortable title="总人数" width="70" v-if="searchobj.bypat == '1'"
            align="center"></vxe-table-column>
          <vxe-table-column field="cnt" sortable title="总标本数" width="70" v-else align="center"></vxe-table-column>
          <vxe-table-column field="S" sortable title="敏感数" width="70" align="center"></vxe-table-column>
          <vxe-table-column field="I" sortable title="中介数" width="70" align="center"></vxe-table-column>
          <vxe-table-column field="R" sortable title="耐药数" width="90" align="center"></vxe-table-column>
          <vxe-table-column field="Srates" sortable title="敏感率%" width="120" align="center"></vxe-table-column>
          <vxe-table-column field="Irates" sortable title="中介率%" width="120" align="center"></vxe-table-column>
          <vxe-table-column field="Rrates" sortable title="耐药率%" width="120" align="center"></vxe-table-column>
        </vxe-table>
      </div>
    </div>

    <!--多选弹窗--->
    <el-dialog width="900px" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" :title="multichktitle"
      :visible.sync="dialogMultipleVisible" :destroy-on-close="true">
      <rm-SqlMultiple :leftOption="option1" :rightOption="option2" :name="fieldname"
        @change="closedialog"></rm-SqlMultiple>
    </el-dialog>
  </div>
</template>

<script type="text/javascript">
import XEUtils from "xe-utils";
export default {
  name: "LIS941",
  data() {
    return {
      sexOption: [
        { label: "", value: "" },
        { label: "男", value: "1" },
        { label: "女", value: "2" },
        { label: "未知", value: "3" },
      ],
      dialogMultipleVisible: false,
      rptStyleSettingState: false,
      option1: [],
      option2: [],
      fieldname: "",
      tableColumn: [],
      tableData: [],
      xTablekey: 0,
      datename: "标本日期",
      multichktitle: "",
      datecode: "1",
      loading: false,
      txtstasticsmod: "", //弹窗统计模版
      stasticsmodOption: [], //统计模版列表
      txtquerymod: "", //查询模版
      querymodOption: [], //查询模版列表
      pattypeOption: [],
      deptOption: [],
      wardOption: [],
      hospOption: [],
      doctorOption: [],
      rptunitGroupOption: [],
      reportcommOption: [],
      labgroupOption: [],
      specimenOption: [],
      deptgroupOption: [], //deptcomb
      germOption: [],
      resdictOption: [],
      labmedOption: [],
      germcombOption: [],
      //以下为查询条件
      searchobj: {
        strdate: this.$pub.InitDateTime2(0).datefrom,
        enddate: this.$pub.InitDateTime2(0).dateto,
        sample: "",
        pattype: "",
        patsex: "",
        rptunitid: "",
        hospitalcode: "",
        reqdept: "",
        reqward: "",
        germcomb: "",
        germrptitemcode: "",
        rescode: "",
        labmed: "",
        chkEmptyAs0: "",
        bypat: 0,
        bygerm: 0,
        bytype: '0',
        deletedup: 1,
      },

      //以下为统计项目
      rp_result4: false,
      rp_rptunitname: false,
      rp_specimen_name: false,
      rp_rpt_itemname: false,
      rp_hospitalcode: false,
      rp_pat_typecode: false,
      rp_pat_sex: false,
      rp_req_wardno: false,
      rp_req_deptno: false,
      rp_pat_diag: false,
      rp_pat_diag_icd: false,
      rp_sampleyear: false,
      rp_samplemonth: false,
      rp_sampleday: false,
      //以下为排序数组
      sortArr: [],
      SortTableColumn: [
        { title: "序号", field: "cp_samplecnt" },
        { title: "抗生素", field: "cp_cnt" },
        { title: "总标本数", field: "cp_amt" },
        { title: "敏感数", field: "cp_rs" },
        { title: "中介数", field: "cp_redocnt" },
        { title: "耐药数", field: "cp_amt" },
        { title: "敏感%", field: "cp_rs" },
        { title: "中介%", field: "cp_redocnt" },
        { title: "耐药%", field: "cp_redocnt" },
      ],
      userno: this.$tool.getSession(this.$tool.loginuserno),
      rptunitname: "",
      exportTableColLen: 0,
      resname: "",
    };
  },
  mounted() {
    this.initOption();
    this.getLoginutype();
    this.InitPage(); //初始化主列表
  },
  updated() { },
  methods: {
    popMultipleChk(e, fieldname, option, title) {
      let temp = XEUtils.clone(option, true);
      this.option1 = [];
      this.option2 = [];
      if (e != "") {
        let k = e.split(",");
        k.forEach((item) => {
          let ndata = temp.find((m) => m.data == item);
          if (ndata != undefined && ndata != null) {
            this.option2.push(ndata);
          }
        });
        temp.forEach((item) => {
          if (k.indexOf(item.data + "") < 0) {
            this.option1.push(item);
          }
        });
      } else {
        this.option1 = temp;
      }
      this.fieldname = fieldname;
      this.multichktitle = title;
      this.dialogMultipleVisible = true;
    },
    closedialog(value, name) {
      if (value != "close") {
        this.searchobj[name] = value;
      }
      this.dialogMultipleVisible = false;
    },
    handleCommand(name) {
      this.datename = name;
      if (name == "标本日期") {
        this.datecode = "1";
      } else if (name == "接收日期") {
        this.datecode = "2";
      } else {
        this.datecode = "3";
      }
    },
    initOption() {
      this.$tool.request({
        url: "LIS/LIS9/LIS941",
        method: "post",
        data: {
          action: "initOption",
        },
      })
        .then((res) => {
          this.pattypeOption = res.pattypeOption;
          this.deptOption = res.deptOption;
          this.hospOption = res.hospOption;
          this.doctorOption = res.doctorOption;
          this.rptunitGroupOption = res.rptunitGroupOption;
          this.reportcommOption = res.reportcommOption;
          this.wardOption = res.wardOption;
          this.labgroupOption = res.labgroupOption;
          this.specimenOption = res.specimenOption;
          this.userOption = res.userOption;
          this.germOption = res.germOption;
          this.resdictOption = res.resdictOption;
          this.labmedOption = res.labmedOption;
          this.germcombOption = res.germcombOption;
        })
        .catch((e) => {
          this.loading = false;
          this.$message.warning(e);
        });
    },
    getLoginutype() {
      let loginutype = this.$tool.getSession(this.$tool.loginutype);
      if (loginutype == "G") {
        this.rptStyleSettingState = true;
      }
    },
    BtnQuery() {
      this.InitPage();
    },
    BtnSort() {
      this.$rmsort(
        { tableColumn: this.SortTableColumn, sortArr: this.sortArr },
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then((res) => {
          this.sortArr = res.data;
          this.InitPage();
        })
        .catch(() => { });
    },
    BtnClear() {
      this.searchobj = {
        strdate: this.$pub.InitDateTime2(0).datefrom,
        enddate: this.$pub.InitDateTime2(0).dateto,
        sample: "",
        pattype: "",
        patsex: "",
        rptunitid: "",
        hospitalcode: "",
        reqdept: "",
        reqward: "",
        germcomb: "",
        germrptitemcode: "",
        rescode: "",
        labmed: "",
        chkEmptyAs0: "",
        bypat: 0,
        bygerm: 0,
        bytype: '0',
        deletedup: 1,
      };

      this.tableData = [];
    },
    resChange(code, name) {
      this.searchobj.rescode = code;
      this.resname = name;
    },
    BtnExport() {
      // this.tableColumn = [];
      // let tableColumn = this.$refs.xTable.getColumns();
      // tableColumn.forEach((item) => {
      //     this.tableColumn.push({ title: item.title, field: item.property });
      // });
      // this.$pub.exportTableExcel(this.tableData, this.tableColumn, "LIS941 抗生素敏感度.xlsx");
      let data = this.getExportData();
      let filtertxt = this.getExportFilter();
      this.$pub.exportTableExcelWithData(data, this.exportTableColLen, "LIS941 抗生素敏感度.xlsx", filtertxt, "统计条件：");
    },
    // 获取当前导出文件的所有查询条件
    getExportFilter() {
      let filtertxt = this.datename + ":" + XEUtils.toDateString(this.searchobj.strdate, "yyyy-MM-dd") + "至" + XEUtils.toDateString(this.searchobj.enddate, "yyyy-MM-dd") + "; ";
      if (this.searchobj.germcomb) filtertxt += "细菌组:" + this.getOptionName(this.germcombOption.filter((item) => ("," + this.searchobj.germcomb + ",").indexOf("," + item.data + ",") > -1)) + "; ";
      if (this.searchobj.pattype) filtertxt += "病人类型:" + this.getOptionName(this.pattypeOption.filter((item) => this.searchobj.pattype == item.data)) + "; ";
      if (this.searchobj.patsex) filtertxt += "病人性别:" + this.getOptionName(this.sexOption.filter((item) => this.searchobj.patsex == item.value)) + "; ";
      if (this.searchobj.reqdept) filtertxt += "申请科室:" + this.getOptionName(this.deptOption.filter((item) => ("," + this.searchobj.reqdept + ",").indexOf("," + item.data + ",") > -1)) + "; ";
      if (this.searchobj.rptunitid) filtertxt += "报告单元:" + this.rptunitname + "; ";
      if (this.searchobj.germrptitemcode) filtertxt += "细菌:" + this.getOptionName(this.germOption.filter((item) => ("," + this.searchobj.germrptitemcode + ",").indexOf("," + item.data + ",") > -1)) + "; ";
      if (this.searchobj.hospitalcode) filtertxt += "送检医院:" + this.hospitalname + "; ";
      if (this.searchobj.reqward) filtertxt += "申请病区:" + this.getOptionName(this.wardOption.filter((item) => ("," + this.searchobj.reqward + ",").indexOf("," + item.data + ",") > -1)) + "; ";
      if (this.searchobj.labmed) filtertxt += "抗生素:" + this.getOptionName(this.labmedOption.filter((item) => ("," + this.searchobj.labmed + ",").indexOf("," + item.data + ",") > -1)) + "; ";
      if (this.searchobj.rescode) filtertxt += "耐药机制:" + this.resname + "; ";
      if (this.searchobj.sample) filtertxt += "标本类型:" + this.getOptionName(this.specimenOption.filter((item) => ("," + this.searchobj.sample + ",").indexOf("," + item.data + ",") > -1)) + "; ";

      if (this.searchobj.bypat == "1") filtertxt += "按病人统计; ";
      if (this.searchobj.bygerm == "1") filtertxt += "按细菌统计; ";
      if (this.searchobj.chkEmptyAs0 == "1") filtertxt += "空数值显示为0; ";
      if (this.searchobj.bytype) filtertxt += "统计方式:" + (this.searchobj.bytype == "0" ? "样本类型" : this.searchobj.bytype == "1" ? "申请科室" : this.searchobj.bytype == "2" ? "送检医院" : "全部") + "; ";
      return filtertxt;
    },
    getOptionName(option) {
      if (option && option.length > 0) {
        let optionname = "";
        option.forEach((item) => {
          if (item.hasOwnProperty("display")) {
            optionname += item.display + ",";
          } else {
            optionname += item.label + ",";
          }
        });
        return optionname.substring(0, optionname.length - 1);
      } else {
        return "";
      }
    },
    getExportData(index) {
      let datas = this.$refs.xTable.afterFullData;
      let exportColumn = XEUtils.clone(this.$refs.xTable.getColumns(), true);
      if (this.searchobj.bytype == '0') {
        exportColumn.push({ field: "bytypename", title: "样本类型" });
      } else if (this.searchobj.bytype == '1') {
        exportColumn.push({ field: "bytypename", title: "申请科室" });
      } else if (this.searchobj.bytype == '2') {
        exportColumn.push({ field: "bytypename", title: "送检医院" });
      }
      if (this.searchobj.bygerm == "1") {
        exportColumn.push({ field: "rpt_itemname", title: "细菌" });
      }

      exportColumn.push({ field: "medname", title: "抗生素" });
      if (this.searchobj.bypat == "1") {
        exportColumn.push({ field: "cnt", title: "总人数" });
      } else {
        exportColumn.push({ field: "cnt", title: "总标本数" });
      }
      exportColumn.push({ field: "S", title: "敏感数" });
      exportColumn.push({ field: "I", title: "中介数" });
      exportColumn.push({ field: "R", title: "耐药数" });
      exportColumn.push({ field: "Srates", title: "敏感率%" });
      exportColumn.push({ field: "Irates", title: "中介率%" });
      exportColumn.push({ field: "Rrates", title: "耐药率%" });
      this.exportTableColLen = exportColumn.length;
      let columns = exportColumn.filter((item) => item.field);
      let footerData = {};
      datas.splice(datas.length, 0, footerData);
      let headers = [columns.map((item) => item.title)];
      return headers.concat(
        datas.map((row) => {
          return columns.map((column) => {
            return this.retForamtVal(row[column.field], column.field);
          });
        })
      );
    },
    BtnPrint(index) {
      let columnArr = [
        { title: "抗生素", property: "medname" },
        { title: "敏感数", property: "S" },
        { title: "中介数", property: "I" },
        { title: "耐药数", property: "R" },
        { title: "敏感率", property: "Srates" },
        { title: "中介率", property: "Irates" },
        { title: "耐药率", property: "Rrates" },
      ];
      if (this.searchobj.bytype == '0') {
        columnArr.push({ title: "样本类型", property: "bytypename" });
      } else if (this.searchobj.bytype == '1') {
        columnArr.push({ title: "申请科室", property: "bytypename" });
      } else if (this.searchobj.bytype == '2') {
        columnArr.push({ title: "送检医院", property: "bytypename" });
      }
      if (this.searchobj.bygerm == "1") {
        columnArr.push({ title: "细菌", property: "rpt_itemname" });
      }
      if (this.searchobj.bypat == "1") {
        columnArr.push({ title: "总人数", property: "cnt" });
      } else {
        columnArr.push({ title: "总标本数", property: "cnt" });
      }
      columnArr.push({ title: "检验日期", property: "chkdate" });
      columnArr.push({ title: "单元", property: "rptunitname" });
      let str = JSON.stringify(columnArr);
      str += "\r";
      str += JSON.stringify(this.$refs.xTable.afterFullData);
      let sql = btoa(encodeURIComponent(str));
      if (index == "1") {
        jsObj.PrintCustomJsonReport("5032", sql, this.userno, "抗生素敏感度统计", "");
      } else {
        jsObj.SetCustomJsonPrintConfig("5032", sql, this.userno, "抗生素敏感度统计");
      }
    },
    InitPage() {
      this.loading = true;
      this.$tool
        .request({
          url: "LIS/LIS9/LIS941",
          method: "post",
          data: {
            action: "InitPage",
            datecode: this.datecode,
            //sortArr: this.sortArr, //排序
            ...this.searchobj,
          },
        })
        .then((response) => {
          this.loading = false;
          this.tableColumn = response.Cols;
          response.Data.forEach((item) => {
            item.chkdate = this.searchobj.strdate + "至" + this.searchobj.enddate;
            item.rptunitname = this.rptunitname;
          });
          this.tableData = response.Data;
        })
        .catch((e) => {
          this.loading = false;
          this.$message.warning(e);
        });
    },
    TypeChange() {
      this.tableData = []
      this.InitPage()
    },
    hospitalchange(code, name) {
      this.searchobj.hospitalcode = code;
      this.hospitalname = name;
    },
    rptunitChange(n, c) {
      this.searchobj.rptunitid = n;
      this.rptunitname = c;
    },
    rowspanMethod({ row, $rowIndex, column, data }) {
      let fields = ["rpt_itemname", "bytypename"];
      // let cellValue = row[column.property];
      let cellValue = row[column.property]
      if (fields.includes(column.property)) {
        let prevRow = data[$rowIndex - 1]
        let nextRow = data[$rowIndex + 1]
        if (prevRow && prevRow[column.property] === cellValue) {
          return { rowspan: 0, colspan: 0 }
        } else {
          let countRowspan = 1
          while (nextRow && nextRow[column.property] === cellValue) {
            nextRow = data[++countRowspan + $rowIndex]
          }
          if (countRowspan > 1) {
            return { rowspan: countRowspan, colspan: 1 }
          }
        }
      }
    },
    formatFun({ cellValue, column, row }) {
      return this.retForamtVal(cellValue, column.property);
    },
    retForamtVal(cellValue, column) {
      if (
        ["bytypename"].includes(column) &&
        this.searchobj.bytype == "0"
      ) {
        try {
          let specimen_name = this.specimenOption.find(
            (m) => m.data == cellValue
          )
          if (specimen_name != undefined && specimen_name != null) {
            return specimen_name.display
          } else {
            return cellValue
          }
        } catch { }
      } else if (
        ["bytypename"].includes(column) &&
        this.searchobj.bytype == "1"
      ) {
        try {
          let deptname = this.deptOption.find(
            (m) => m.data == cellValue
          )
          if (deptname != undefined && deptname != null) {
            return deptname.display
          } else {
            return cellValue
          }
        } catch { }
      } else if (
        ["bytypename"].includes(column) &&
        this.searchobj.bytype == "2"
      ) {
        try {
          let hospname = this.hospOption.find(
            (m) => m.data == cellValue
          )
          if (hospname != undefined && hospname != null) {
            return hospname.display
          } else {
            return cellValue
          }
        } catch { }
      } else {
        return cellValue
      }
    },

  },
};
</script>

<style scoped>
.pagetop {
  width: 100%;
  height: 130px;
  display: -webkit-box;
  -webkit-box-pack: left;
  -webkit-box-align: center;
  border: 1px solid #ccc;
  position: absolute;
  z-index: 99;
}

/* ::v-deep .pagetop .el-radio {
    margin-right: 10px !important;
}
::v-deep .pagetop .el-checkbox {
    margin-left: 15px;
} */

.pagecenter {
  position: absolute;
  top: 135px;
  width: 100%;
  left: 0;
  bottom: 0px;
  overflow: auto;
}

.middle-center {
  position: absolute;
  height: 100%;
  left: 0px;
  right: 0px;
  overflow: auto;
}

.el-checkbox__label {
  padding: 0px;
}

.left_nav {
  width: 20%;
  height: 100%;
  border-right: 1px solid #ccc;
  padding: 0px 0px 0px 0px;
  float: left;
  display: inline;
}

.left_nav div {
  cursor: pointer;
  height: 40px;
  width: 100%;
  float: left;
  padding-left: 20px;
  line-height: 40px;
}

.left_nav .active {
  background-color: DeepSkyBlue;
}

.right_nav {
  width: 80%;
  height: 100%;
  display: inline-block;
  vertical-align: top;
  float: left;
  display: inline;
}

table {
  font-size: 12px;
  border-collapse: separate;
  border-spacing: 5px;
}

.table1style tr td {
  padding: 0px 2px 0px 5px;
}

::v-deep .mytable-style .vxe-footer--column.col-blue {
  color: blue !important;
  font-weight: bold;
}

::v-deep .mytable-style .vxe-body--row.row-blue {
  color: blue !important;
  font-weight: bold;
}

::v-deep .el-checkbox__label {
  padding-left: 0px;
}

::v-deep .el-icon-time {
  line-height: 18px !important;
}

::v-deep .el-range__close-icon {
  line-height: 18px !important;
}

::v-deep .el-range-editor--small .el-range-separator {
  line-height: 17px !important;
}</style>
